package cn.snmp.mutual.uk.pdu;

import java.util.*;
import java.io.*;
import cn.snmp.mutual.uk.stack.*;

public class DiscoveryPdu extends GetPdu {
    private static final String version_id = "@(#)$Id: DiscoveryPdu.java,v 3.15 2006/11/29 16:12:50 birgit Exp $ Copyright Westhawk Ltd";
    private SnmpContextv3Face context;

    public DiscoveryPdu(final SnmpContextv3Face cntxt) {
        super(cntxt);
        this.context = cntxt;
    }

    @Override
    public void addOid(final String oid) throws IllegalArgumentException {
        throw new IllegalArgumentException("DiscoveryPdu cannot have OID");
    }

    @Override
    public void addOid(final String oid, final AsnObject val) {
        throw new IllegalArgumentException("DiscoveryPdu cannot have OID");
    }

    @Override
    public void addOid(final AsnObjectId oid, final AsnObject val) {
        throw new IllegalArgumentException("DiscoveryPdu cannot have OID");
    }

    @Override
    public void addOid(final Varbind var) throws IllegalArgumentException {
        throw new IllegalArgumentException("DiscoveryPdu cannot have OID");
    }

    @Override
    public void addOid(final AsnObjectId oid) {
        throw new IllegalArgumentException("DiscoveryPdu cannot have OID");
    }

    @Override
    public boolean send() throws IOException, PduException {
        if (!this.added) {
            this.added = this.context.addDiscoveryPdu(this);
        }
        final Enumeration vbs = this.reqVarbinds.elements();
        this.encodedPacket = this.context.encodeDiscoveryPacket(this.msg_type, this.getReqId(), this.getErrorStatus(), this.getErrorIndex(), vbs, this.snmpv3MsgId);
        this.addToTrans();
        return this.added;
    }
}
